'use strict';

import Base from './base.js';


export default class extends Base {
    /**
     * index action
     * @return {Promise} []
     */
    async indexAction(){
        let username = this.param('username'),
            password = this.param('password');
        let loginServiceObj = this.service("login"),
            loginService = new loginServiceObj();
        if(loginService.verifyUser(username,password)){
            let token =  loginService.createToken({username:username});
            await this.session("token", token);
            return this.success("SUCCESS");
        }else{
            return this.fail(1001,'用户名或密码错误',"");
        }

    }
}